<script>
export  default {
  props:{
    imgUrl:{
      type:String,
      default: 'https://image.hzwltb69.com/app/date/2023/defaultAvatar.png'
    }
  },
  data(){
    return{

    }
  },
  methods:{
    onUpload(){
      this.upload()
    },
    upload(){
      uni.chooseImage({
        count: 1,
        success: (res) => {
          console.log(res.tempFiles[0])
          uni.uploadFile({
            url: 'https://www.hzwltb69.com/api/common/file/upload',
            filePath: res.tempFiles[0].path,
            name: 'file',
            success: (res) => {
              this.$emit('uploadSuccess', JSON.parse(res.data).url)
            },
            fail: (err) => {
              console.log(err)
            }

          })
        },
        fail: (err) => {
          console.log(err)
        }
      })

    }
  }
}
</script>
<template>
  <view class="box">
    <view class="img-box">
      <image
          :src="imgUrl"
          mode="aspectFill"
          class="ljshop-image"
          @tap="onUpload"
      ></image>
    </view>
  </view>
</template>
<style lang="scss" scoped>
.box{
  .img-box{
    border-radius: 50%;
    width: 100rpx;
    height: 100rpx;
    //background: red;
    overflow: hidden;
  }
}
</style>